﻿using System;
using System.Collections;
using System.Collections.Generic;

using AUV5.Model;
using AUV5.DAL.Interface;

namespace AUV5.DAL.Dao
{
    /// <summary>
    /// 功能：     ServiceCategory业务接口的实现
    /// 作者：     lwl
    /// 日期：     2011/10/14
    /// 修改日期： 
    /// 修改人：
    /// 修改内容：
    /// </summary>
    public class ServiceCategorySqlMapDao : BaseSqlMapDao, IServiceCategoryDao
    {
        private static ServiceCategorySqlMapDao instance = null;
        private static object syncRoot = new object();

        private ServiceCategorySqlMapDao()
        {
            //
            // TODO: 此处添加ServiceCategorySqlMapDao的构造函数
            //
        }
        public static IServiceCategoryDao Instance
        {
            get
            {
                if (instance == null)
                {
                    lock (syncRoot)
                    {
                        if (instance == null)
                        {
                            instance = new ServiceCategorySqlMapDao();
                        }
                    }
                }
                return instance;
            }
        }

        /// <summary>
        /// 得到最大行数
        /// </summary>
        /// <returns></returns>
        public int GetMaxCounts()
        {
            try
            {
                return (int)ExecuteQueryForObject("SelectServiceCategoryByMaxCounts", null);
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 得到列表
        /// </summary>
        /// <returns></returns>
        public System.Collections.Generic.IList<ServiceCategory> GetList()
        {
            try
            {
                return ExecuteQueryForList<ServiceCategory>("SelectServiceCategory", null);
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 通过不同参数得到列表
        /// </summary>
        /// <param name="objParameters"></param>
        /// <returns></returns>
        public System.Collections.Generic.IList<ServiceCategory> GetListByParameters(object objParameters)
        {
            try
            {
                return ExecuteQueryForList<ServiceCategory>("SelectServiceCategoryByParameters", objParameters);
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 得到明细
        /// </summary>
        /// <param name="CategoryID"></param>
        /// <returns></returns>
        public ServiceCategory GetDetail(ServiceCategory category)
        {
            try
            {
                return ExecuteQueryForObject<ServiceCategory>("SelectServiceCategory", category) as ServiceCategory;
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 新建
        /// </summary>
        /// <param name="servicecategory"></param>
        /// <returns></returns>
        public object Add(ServiceCategory servicecategory)
        {
            try
            {
                return ExecuteInsert("InsertServiceCategory", servicecategory);
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="servicecategory"></param>
        /// <returns></returns>
        public int Update(ServiceCategory servicecategory)
        {
            try
            {
                return ExecuteUpdate("UpdateServiceCategory", servicecategory);
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="CategoryID"></param>
        /// <returns></returns>
        public int Delete(System.String categoryid)
        {
            try
            {
                return ExecuteDelete("DeleteServiceCategory", categoryid);
            }
            catch
            {
                throw;
            }
        }
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="servicecategory"></param>
        /// <returns></returns>
        public int Delete(ServiceCategory servicecategory)
        {
            try
            {
                return ExecuteDelete("DeleteServiceCategory", servicecategory.CategoryID);
            }
            catch
            {
                throw;
            }
        }


        #region 获取服务类别的JSon数据
        /// <summary>
        /// 获取服务类别的JSon数据
        /// </summary>
        /// <returns></returns>
        public string GetJsonList()
        {
            Handler.JsonHandler handler = new Handler.JsonHandler();
            ExecuteWithRowDelegate("SelectServiceCategory", null, new IBatisNet.DataMapper.RowDelegate(handler.ParseJson));
            return handler.json;
        }
        #endregion
        
    }
}
